﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using Aij1.Model;
using DevExpress.Data.Filtering;
using System.Web;

namespace Aij1.BLL
{
    public class CategoryData
    {
        public static XPCollection<A_Category> GetCategorys(Session session)
        {
            var cats = new XPCollection<A_Category>(session);
            cats.Sorting.Add(new SortProperty("OrderId", DevExpress.Xpo.DB.SortingDirection.Ascending));
            return cats;
        }

        public static XPCollection<A_Category> GetCategorys(Session session, ArticleType catType)
        {
            var cats = new XPCollection<A_Category>(session, CriteriaOperator.Parse("AType=?", catType));
            cats.Sorting.Add(new SortProperty("OrderId", DevExpress.Xpo.DB.SortingDirection.Ascending));
            return cats;
        }

        public static IList<T> GetTypes<T>()
        {
            List<T> types = new List<T>();
            foreach (var a in Enum.GetValues(typeof(T)))
            {
                types.Add((T)a);
            }
            return types;
        }
    }
}
